#include <iostream>
#include <climits>
#define MAX_SIZE 505
using namespace std;

int g[MAX_SIZE][MAX_SIZE],rescue[MAX_SIZE],dist[MAX_SIZE],max_rescue[MAX_SIZE],path_num[MAX_SIZE];
bool set[MAX_SIZE]; 
void dijkstra(int n){
	while( true ){
		int v = -1,min = INT_MAX;
		for(int i=0; i<n; i++){
			if( !set[i] && dist[i]<min ){
				v = i;
				min = dist[i];
			}
		}
		if( v==-1 ) break;
		set[v] = true;	//find the shortest distance of vertex to source
		for( int i=0; i<n; i++){
			if( !set[i] && g[v][i] ){
				if( g[v][i]+dist[v] < dist[i] ){
					dist[i] = g[v][i] + dist[v];
					path_num[i] = path_num[v];
					max_rescue[i] = max_rescue[v] + rescue[i];	
				}else if( g[v][i]+dist[v] == dist[i] ){
					path_num[i] += path_num[v];
					if( max_rescue[i] < max_rescue[v]+rescue[i] )
						max_rescue[i] = max_rescue[v] + rescue[i];
				}
			}
		}
	}
}
int main(){
	freopen("in.txt","r",stdin);
	int n,m,c1,c2;
	cin >> n >> m >> c1 >> c2;
	for(int i=0; i<n; i++){
		cin >> rescue[i];
		dist[i] = INT_MAX;	
	}
	path_num[c1] = 1;
	max_rescue[c1] = rescue[c1];
	dist[c1] = 0;
	for(int i=0; i<m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		g[a][b] = g[b][a] = c;
	}
	dijkstra(n);
	cout << path_num[c2] << " " << max_rescue[c2];
	return 0;
}
